<?php
class Dao {

    private $connection;    

    private function connectDB() {

		//Online
        $onlineTableName = "ran49406_scms";
        $onlineUserName = "ran49406_scms";
        $onlinePassword = "Fishy2009";
        $onlineLocation = "localhost";
		
		//Offline
        $offlineTableName = "3120S109g04";
        $offlineUserName = "3120S109g04";
        $offlinePassword = "b39b80698b";
        $offlineLocaction = "dunk.it.jcu.edu.au/3120S109g04";    		

        if ( $this->connection = mysql_connect($onlineLocation, $onlineUserName, $onlinePassword) ) {
			if ( !$db = mysql_select_db($onlineTableName) ) die('Cannot find database');
		}
		else if ( $this->connection = mysql_connect($offlineLocation, $offlineUserName, $offlinePassword) ) {
			if ( !$db = mysql_select_db($offlineTableName) ) die('Cannot find database');
		}
		else {
			die('Connection to Online and Offline Databases failed.');
		}
    }

    public function pharseQ($query) {
        $this->connectDB();
        $result = mysql_query($query);

        mysql_close($this->connection);

        return $result;
    }
}

?>
